public class MyThread extends Thread {

    public MyThread(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i=0;i<5;i++){
            System.out.println(Thread.currentThread().getName()+"线程正在执行！");
        }
    }

    public static void main(String[] args) {

        // 创建当前类对象
        MyThread thread1 = new MyThread("thread1");
        thread1.start(); // 线程启动后要去调用run方法，按cpu分配的时间片执行

        MyThread thread2 = new MyThread("thread2");
        thread2.start();
    }

}
